package cn.edu.guet.service.editor.impl;

import cn.edu.guet.bean.editor.Comment;
import cn.edu.guet.mapper.editor.ComMapper;
import cn.edu.guet.service.editor.IComService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class comService implements IComService {
    @Autowired
    private ComMapper comMapper;
    //获取父评论
    @Override
    public List<Comment> getFatherCom(int pid) {
        return comMapper.getFatherCom(pid);
    }
    //增加评论
    @Override
    public void insertReply(Comment comment){
        comMapper.insertReply(comment);
    }
    //用户进行点赞
    @Override
    public void updateComUp(int comid,int userid) {
        comMapper.updateComUp(comid);
        comMapper.alreadyComUp(comid,userid);
    }

    //用户取消点赞
    @Override
    public void deleteComUp(int comid,int userid) {
        comMapper.deleteComUp(comid);
        comMapper.deleteComUpRecord(comid,userid);
    }

    //查看用户是否已点赞评论
    @Override
    public String selectComUpRecord(int comid, int userid) {
        return comMapper.selectComUpRecord(comid,userid);
    }
}
